From e78bded5f0758ef3430535bc4ab293099a49e03c Mon Sep 17 00:00:00 2001 From: robertl Date: Fri, 16 Jan 2004 03:50:37 +0000 Subject: [PATCH] Add -vs status indicator to most file formats. Fix magellan serial timeouts under Windows. --- gpsbabel/Makefile | 4 ++-- gpsbabel/defs.h | 1 + gpsbabel/garmin.c | 7 +++++++ gpsbabel/magproto.c | 12 ++++++++---- gpsbabel/main.c | 9 +++++++++ gpsbabel/waypt.c | 8 ++++++++ 6 files changed, 35 insertions(+), 6 deletions(-) diff --git a/gpsbabel/Makefile b/gpsbabel/Makefile index 368c55879..a3c32d4c5 100644 --- a/gpsbabel/Makefile +++ b/gpsbabel/Makefile @@ -78,8 +78,8 @@ dep: (echo -n "internal_styles.c: mkstyle.sh " ; echo style/*.style ; /bin/echo -e '\t./mkstyle.sh > $@ || (rm -f $@ ; exit 1)' ) >> /tmp/dep echo Edit Makefile and bring in /tmp/dep -VERSIONU=1_2_1_beta01112004 -VERSIOND=1.2.1_beta01112004 +VERSIONU=1_2_1_beta01152004 +VERSIOND=1.2.1_beta01152004 #VERSIONU=1_2_1 #VERSIOND=1.2.1 diff --git a/gpsbabel/defs.h b/gpsbabel/defs.h index 8c96609d3..cb08cbbc5 100644 --- a/gpsbabel/defs.h +++ b/gpsbabel/defs.h @@ -63,6 +63,7 @@ typedef struct { int synthesize_shortnames; int debug_level; gpsdata_type objective; + int verbose_status; /* set by GUI wrappers for status */ } global_options; extern global_options global_opts; diff --git a/gpsbabel/garmin.c b/gpsbabel/garmin.c index 7d8dbc2de..51d3beb1f 100644 --- a/gpsbabel/garmin.c +++ b/gpsbabel/garmin.c @@ -350,6 +350,10 @@ waypoint_write(void) if (wpt->altitude != unknown_alt) { way[i]->alt = wpt->altitude; } + if (global_opts.verbose_status) { + fprintf(stdout, "%d\r", i*100/n); + fflush(stdout); + } i++; } if ((ret = GPS_Command_Send_Waypoint(portname, way, n)) < 0) { @@ -359,6 +363,9 @@ waypoint_write(void) for (i = 0; i < n; ++i) { GPS_Way_Del(&way[i]); } + if (global_opts.verbose_status) { + fprintf(stdout, "\r\n"); + } xfree(way); } diff --git a/gpsbabel/magproto.c b/gpsbabel/magproto.c index fb1c6bce1..56c65d167 100644 --- a/gpsbabel/magproto.c +++ b/gpsbabel/magproto.c @@ -549,8 +549,10 @@ terminit(const char *portname) } GetCommTimeouts (comport, &timeout); - timeout.ReadIntervalTimeout = 10; - timeout.WriteTotalTimeoutMultiplier = 10; + timeout.ReadIntervalTimeout = 100; + timeout.ReadTotalTimeoutMultiplier = 100; + timeout.ReadTotalTimeoutConstant = 100; + timeout.WriteTotalTimeoutMultiplier = 100; timeout.WriteTotalTimeoutConstant = 1000; if (!SetCommTimeouts (comport, &timeout)) { xCloseHandle (comport); @@ -573,11 +575,13 @@ termread(char *ibuf, int size) for(;i < size;i++) { if (ReadFile (comport, &ibuf[i], 1, &cnt, NULL) != TRUE) break; - if (ibuf[i] == '\n') break; + if (cnt < 1) + return NULL; + if (ibuf[i] == '\n') + break; } ibuf[i] = 0; return ibuf; - } static void diff --git a/gpsbabel/main.c b/gpsbabel/main.c index 704336c45..6c63cccc6 100644 --- a/gpsbabel/main.c +++ b/gpsbabel/main.c @@ -186,6 +186,15 @@ main(int argc, char *argv[]) ? argv[argn]+2 : argv[++argn]; global_opts.debug_level = atoi(optarg); break; + /* + * Undocumented '-vs' option for GUI wrappers. + */ + case 'v': + switch(argv[argn][2]) { + case 's': global_opts.verbose_status = 1; break; + } + break; + /* * DOS-derived systems will need to escape * this as -^^. diff --git a/gpsbabel/waypt.c b/gpsbabel/waypt.c index 5e2831db6..8e082d6a1 100644 --- a/gpsbabel/waypt.c +++ b/gpsbabel/waypt.c @@ -137,11 +137,19 @@ waypt_disp_all(waypt_cb cb) { queue *elem, *tmp; waypoint *waypointp; + int i = 0; QUEUE_FOR_EACH(&waypt_head, elem, tmp) { waypointp = (waypoint *) elem; + if (global_opts.verbose_status) { + fprintf(stdout, "%d\r", ++i*100/waypt_ct); + fflush(stdout); + } (*cb) (waypointp); } + if (global_opts.verbose_status) { + fprintf(stdout, "\r\n"); + } } waypoint * -- 2.30.2